home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / Libraries / SAT 2.3b4 / Demo ƒ / myPlatform demo ƒ / myPlatform.c < prev    next >
C/C++ Source or Header  |  1995-01-17  |  2KB  |  89 lines

  1. #include "SAT.h"
  2.  
  3. /**************/
  4. /* myPlatform demo*/
  5. /**************/
  6.  
  7. /* This demo is a hack I made, testing if we can use faceless sprites to make stationary*/
  8. /* obstacles. That worked pretty nicely, so I went on and made some moving platforms too.*/
  9. /* Take it for what it is: a test hack that suggests one way to make this kind of games.*/
  10. /* There are many other ways. The controls can be improved a lot, but it is a start.*/
  11.  
  12. /* Translated to C by Mike Zimmerman */
  13.  
  14. #include "myPlatform.h"
  15.  
  16. SATPatHandle    thepat;
  17. long             l;
  18. SpritePtr        ignoreSp;
  19. Point            p;
  20.  
  21. void DrawInfo()
  22. {
  23.     Rect    r;
  24.     
  25.     SATSetPortBackScreen();
  26.     SetRect(&r, 100, 50, 300, 100);
  27.     EraseRect(&r);
  28.     FrameRect(&r);
  29.     MoveTo(110, 70);
  30.     DrawString("\pSAT Platform demo");
  31.     MoveTo(110, 90);
  32.     DrawString("\pMove with , . and space");
  33.     SATBackChanged(&r);
  34. }
  35.  
  36.  
  37. main()
  38. {
  39.     Rect        tempRect;
  40.  
  41.     SATInitToolbox();
  42.  
  43.     SATConfigure(true, kLayerSort, kBackwardCollision, 32);
  44.     SATInit(0, 0, 512, 322);  /* No PICTs */
  45.  
  46.     /* Use a background pattern (instead of PICTs - just to demo that too) */
  47.     
  48.     SATSetPortBackScreen();  
  49.     thepat = SATGetPat(128);
  50.     SATPenPat(thepat);
  51.     SetRect(&tempRect, 0, 0, gSAT.offSizeH, gSAT.offSizeV);
  52.     PaintRect(&tempRect);
  53.     
  54.     CopyBits(&(gSAT.backScreen.port)->portBits, &gSAT.offScreen.port->portBits, &gSAT.offScreen.port->portRect, &gSAT.offScreen.port->portRect, srcCopy, nil);
  55.  
  56.     DrawInfo();
  57.     
  58. /*Initialize all sprite units*/
  59.     InitPlayerSprite();
  60.     InitPlatform();
  61.     InitMovPlatform();
  62.     InitHMovPlatform();
  63.     
  64. /*Update the game window once more, so the pattern and what we drawn in DrawInfo are shown. */
  65.     SATRedraw();
  66.     
  67.     GetMouse(&p);
  68.     ignoreSp = SATNewSprite(1, p.h, p.v, &SetupPlayerSprite);
  69.     ignoreSp = SATNewSprite(0, 50, 300, &SetupPlatform);
  70.     ignoreSp = SATNewSprite(0, 150, 200, &SetupPlatform);
  71.     ignoreSp = SATNewSprite(0, 250, 100, &SetupPlatform);
  72.     ignoreSp = SATNewSprite(0, 350, 50, &SetupPlatform);
  73.     ignoreSp = SATNewSprite(0, 350, 300, &SetupMovPlatform);
  74.     ignoreSp = SATNewSprite(0, 50, 200, &SetupMovPlatform);
  75.     ignoreSp = SATNewSprite(0, 200, 150, &SetupHMovPlatform);
  76.  
  77.     HideCursor();
  78.     while (!Button())
  79.     {
  80.         l = TickCount();
  81.         SATRun(true);
  82.         while (l > TickCount() - 2L)
  83.             ;
  84.     }
  85.     ShowCursor();
  86.     SATSetPortScreen();
  87.     SATSoundShutup();
  88. }
  89.